/**
 * 
 */
package com.great.meal.search.domain;

import java.io.Serializable;
import java.util.Set;

import javax.persistence.CascadeType;
import javax.persistence.Entity;
import javax.persistence.GeneratedValue;
import javax.persistence.GenerationType;
import javax.persistence.Id;
import javax.persistence.OneToMany;
import javax.persistence.Table;

/**
 * @author lenovo
 *
 */
@Entity
@Table(name = "t_dishmenu")
public class DishMenu implements Serializable {
	
	/**
	 * 
	 */
	private static final long serialVersionUID = 237790344092961414L;
	private Long dishMenuId;
	private Set<DishItem> dishItems;
	private Double totalMoney;
	
	@Id
	@GeneratedValue( strategy = GenerationType.AUTO)
	public Long getDishMenuId() {
		return dishMenuId;
	}
	
	public void setDishMenuId(Long dishMenuId) {
		this.dishMenuId = dishMenuId;
	}
	
	@OneToMany(cascade=CascadeType.ALL)
	public Set<DishItem> getDishItems() {
		return dishItems;
	}
	
	public void setDishItems(Set<DishItem> dishItems) {
		this.dishItems = dishItems;
	}
	
	public Double getTotalMoney() {
		return totalMoney;
	}
	
	public void setTotalMoney(Double totalMoney) {
		this.totalMoney = totalMoney;
	}

	@Override
	public boolean equals(Object obj) {
		if(this == obj) return true;
		if(!(obj instanceof DishMenu)) return false;
		
		final DishMenu menu = (DishMenu)obj;
		if(!(menu.getDishItems().equals(getDishItems()))) return false;
		if(!(menu.getDishMenuId().equals(getDishMenuId()))) return false;
		
		return true;
	}
	
	@Override
	public int hashCode() {
		int result = dishMenuId != null ? dishMenuId.hashCode() : 0;
		result = 31 * result + (dishItems != null ? dishItems.hashCode() : 0);
		return result;
	}
}
